<html>
<head><meta charset="utf-8"><title>Scatter/Gathers · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html">Scatter/Gathers</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="242482002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242482002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brandon Falk <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242482002">(Jun 13 2021 at 01:05)</a>:</h4>
<p>I know this a big one, but has there been talk on how to implement and handle scatter/gather instructions. I suspect with masks and selects that LLVM might already output them, but I don't know how much I would trust them.</p>



<a name="242482048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242482048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242482048">(Jun 13 2021 at 01:06)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> is in the process of putting together a PR for that!</p>



<a name="242482062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242482062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brandon Falk <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242482062">(Jun 13 2021 at 01:07)</a>:</h4>
<p>Awesome, probably the last thing I think I need to have direct control over to write pretty much anything. LLVM already trivially uses ternlog instructions and FMAs when it detects that pattern. Scatters and gathers will make this usable for all my SIMD code I think!</p>



<a name="242482104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242482104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242482104">(Jun 13 2021 at 01:08)</a>:</h4>
<p>Hmm, LLVM generates FMA?  I think more recent versions of nightly shouldn't since that was probably a bug.</p>



<a name="242482105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242482105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brandon Falk <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242482105">(Jun 13 2021 at 01:08)</a>:</h4>
<p>One thing that'll be kinda tricky is doing scatter/gathers on u16s and stuff, where you don't actually have usize indicies. But it'd also be nice to be able to somehow do scatter/gathers on SimdU16 values, but with usizes (where LLVM/Rust would break it down into the larger pieces, and then join the vectors back)</p>



<a name="242482109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242482109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242482109">(Jun 13 2021 at 01:09)</a>:</h4>
<p>Though we will have an FMA function eventually</p>



<a name="242482111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242482111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brandon Falk <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242482111">(Jun 13 2021 at 01:09)</a>:</h4>
<p>Hmmm, maybe it doesnt? I know it makes ternlog.</p>



<a name="242482174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242482174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242482174">(Jun 13 2021 at 01:10)</a>:</h4>
<p>That's good, I'd expect ternlog to be generated from selects</p>



<a name="242482200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242482200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brandon Falk <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242482200">(Jun 13 2021 at 01:12)</a>:</h4>
<p>Yeah, doesn't look like it generates FMA. What's the reason for that? The internal precision of FMA not matching explicit multiply and add?</p>



<a name="242482291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242482291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242482291">(Jun 13 2021 at 01:14)</a>:</h4>
<p>Yeah, we want every operation to be completely compliant with IEEE 754 (not just vector ops, but scalar too)</p>



<a name="242482349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242482349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brandon Falk <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242482349">(Jun 13 2021 at 01:16)</a>:</h4>
<p>Makes sense!</p>



<a name="242483990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242483990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242483990">(Jun 13 2021 at 02:03)</a>:</h4>
<p>Yeah, the ideal we've wound up angling for is to just have everything be in principle a properly-aligned version of [T; N] that has some syntax sugar and some special parallel ops.</p>



<a name="242484078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242484078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242484078">(Jun 13 2021 at 02:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="356799">Brandon Falk</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Scatter.2FGathers/near/242482105">said</a>:</p>
<blockquote>
<p>One thing that'll be kinda tricky is doing scatter/gathers on u16s and stuff, where you don't actually have usize indicies. But it'd also be nice to be able to somehow do scatter/gathers on SimdU16 values, but with usizes (where LLVM/Rust would break it down into the larger pieces, and then join the vectors back)</p>
</blockquote>
<p>I am... mildly perplexed by what you mean by "don't have usize indices" here?</p>



<a name="242484183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242484183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242484183">(Jun 13 2021 at 02:08)</a>:</h4>
<p>Internally, LLVM takes the stance that scatter/gather is a vector of pointers with a vector mask and a base vector (so it's always actually a <code>select + gather</code> or <code>select + scatter</code>).</p>



<a name="242484220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242484220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242484220">(Jun 13 2021 at 02:09)</a>:</h4>
<p>So unfortunately Rust's portable SIMD API pushes the limits of what rustc and LLVM are capable of understanding. If you wanted LLVM to use an instruction that doesn't use full pointer-width indices, then it might compile to that incidentally but we don't have a meaningful way of expressing that.</p>



<a name="242485296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242485296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brandon Falk <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242485296">(Jun 13 2021 at 02:36)</a>:</h4>
<p>Hmm yeah, this is tough. There's a <code>vpscatterdd</code> which is <code>*(base + [signextend(index32); 16])</code>. Which is strange, 64-bit base, 32-bit indicies. But for a lot of data (&lt;4 GiB) it's usually what you want, especially if you're working with <code>f32</code>s and <code>u32</code>s, which is kinda most of the time for some heavy compute loops</p>



<a name="242485566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242485566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brandon Falk <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242485566">(Jun 13 2021 at 02:42)</a>:</h4>
<p>And you can kinda work around some limitations as you can do <code>vpgatherdd zmm0, [rax + zmm1*8]</code>, where the scalar can be 1, 2, 4, or 8, so you can actually index beyond 4 GiB with a 32-bit int, which is often more than sufficient for indexing even a large data set, without having to break it into 2 instructions to use 64-bit indicies. It's definitely a bit strange</p>



<a name="242485802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242485802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brandon Falk <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242485802">(Jun 13 2021 at 02:46)</a>:</h4>
<p>The actual op for x86 scatter/gathers is <code>base + signextend(index) * scale</code>, where scale is <code>1, 2, 4, 8</code> and index may be 32-bit or 64-bit. There is also <code>dq</code> and <code>qd</code> variants which use 32-bit indicies and fill into 64-bit vectors, and the opposite (conversion + scatter/gather)<br>
<code>vpgatherdq</code></p>
<blockquote>
<p>Gather 64-bit integers from memory using 32-bit indices. 64-bit elements are loaded from addresses starting at base_addr and offset by each 32-bit element in vindex (each index is scaled by the factor in scale). Gathered elements are merged into dst. scale should be 1, 2, 4 or 8.</p>
</blockquote>
<p><code>vpgatherqd</code></p>
<blockquote>
<p>Gather 32-bit integers from memory using 64-bit indices. 32-bit elements are loaded from addresses starting at base_addr and offset by each 64-bit element in vindex (each index is scaled by the factor in scale). Gathered elements are merged into dst. scale should be 1, 2, 4 or 8.</p>
</blockquote>



<a name="242485818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242485818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brandon Falk <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242485818">(Jun 13 2021 at 02:47)</a>:</h4>
<p>Are they worth engineering around? Hard to say, but there are pretty valid uses for this, especially if you want to potentially eliminate two data sets and use one where the conversion is done in the instruction</p>



<a name="242490316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242490316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242490316">(Jun 13 2021 at 04:54)</a>:</h4>
<p>Mmm. If the SIMD gather/scatter using the portable intrinsics doesn't compile to using those instructions ever, then likely it'd be more productive to file a bug against upstream, honestly, because "base pointer + offsets" isn't so wild an idea.</p>



<a name="242493170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242493170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242493170">(Jun 13 2021 at 06:17)</a>:</h4>
<p>Is FMA just fused multiply add but in SIMD vectors?</p>



<a name="242493245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242493245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242493245">(Jun 13 2021 at 06:19)</a>:</h4>
<p>yes.</p>



<a name="242540259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242540259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242540259">(Jun 14 2021 at 00:51)</a>:</h4>
<p>Noice.</p>



<a name="242548832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242548832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242548832">(Jun 14 2021 at 03:57)</a>:</h4>
<p>Anyways the nuances of the AVX gather/scatter API being more apt to the base + offsets model is why I intend to only yield a scatter/gather implementation that tags a single slice per function. We can't <strong>make</strong> LLVM do the right thing, but we can gently... ah... peer pressure it.</p>



<a name="242548835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242548835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242548835">(Jun 14 2021 at 03:57)</a>:</h4>
<p>Hopefully deriving all the pointers from a base pointer will show it the light.</p>



<a name="242549119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242549119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242549119">(Jun 14 2021 at 04:02)</a>:</h4>
<p>I think it would probably be reasonable if that's the only API we exposed, and anything else would need vendor intrinsics</p>



<a name="242552664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242552664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242552664">(Jun 14 2021 at 05:01)</a>:</h4>
<p>I disagree...I think scatter/gather based on vectors of pointers should be the API that we provide -- it should not be relegated to using arch-specific intrinsics, which would be overoptimizing the API for Intel's ISA imho.</p>



<a name="242552822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242552822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242552822">(Jun 14 2021 at 05:05)</a>:</h4>
<p>I don't object to having a scatter/gather API based on array indexing, however I think we would be making a serious mistake to say that array-indexing API is sufficient with no need to add pointer-vector APIs.</p>



<a name="242552948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242552948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242552948">(Jun 14 2021 at 05:07)</a>:</h4>
<p>It's worth noting that SVE also uses a single pointer with type-width offsets</p>



<a name="242552967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242552967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242552967">(Jun 14 2021 at 05:07)</a>:</h4>
<p>It's definitely not Intel-specific</p>



<a name="242553022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242553022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242553022">(Jun 14 2021 at 05:08)</a>:</h4>
<p>I think vectors of pointers are likely not going to be portable or efficient</p>



<a name="242554820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242554820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242554820">(Jun 14 2021 at 05:46)</a>:</h4>
<p>Well, both Intel and Arm SVE support loading from vectors of pointers. One of the SVE gather instructions has 64-bit vector elements for the input vector register, it calculates the addresses by adding a shifted 5-bit immediate to the input 64-bit vector elements, then loads 32-bit words from those addresses and then writes them to the destination vector after zero-extending the loaded words to 64-bits: <a href="https://developer.arm.com/documentation/ddi0602/latest/SVE-Instructions/LD1W--vector-plus-immediate---Gather-load-unsigned-words-to-vector--immediate-index--?lang=en#iclass_64_elem">https://developer.arm.com/documentation/ddi0602/latest/SVE-Instructions/LD1W--vector-plus-immediate---Gather-load-unsigned-words-to-vector--immediate-index--?lang=en#iclass_64_elem</a></p>



<a name="242554843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242554843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242554843">(Jun 14 2021 at 05:47)</a>:</h4>
<p>that instruction is <em>totally</em> useless except for gathering from a vector of pointers</p>



<a name="242555238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242555238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242555238">(Jun 14 2021 at 05:54)</a>:</h4>
<p>since SVE's designers went <em>out of their way</em> to add a whole class of load/store instructions just for use with vectors of pointers (the load/store with vector+immediate address), and since many other architectures also support gather/scatter with vectors of pointers (AVX2, AVX512, Libre-SOC's SimpleV extension for OpenPower, RISC-V V, and more), I think that's sufficient motivation to add support for vectors of pointers.</p>



<a name="242555412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242555412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242555412">(Jun 14 2021 at 05:58)</a>:</h4>
<p>in fact, all gather/scatter ISAs that I'm aware of support vectors of pointers.</p>



<a name="242652542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242652542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242652542">(Jun 14 2021 at 20:07)</a>:</h4>
<p>As far as I am concerned the real issue is programming ergonomics, and manipulating pointers is tricky. A safe, slice-oriented API satisfies most needs here without tying us too tightly to implementation details, and it will hopefully compile in a reasonably efficient way.</p>
<p>As we encounter more exotic concerns, we can address those on a case-by-case basis, and eventually we may expose such an API as you propose, Jacob, but really... pointers have a lot of unsettled questions and we're already in Ralf's face every five seconds to ask questions about target feature and const eval related stuff. I want to give the man a chance to catch his breath before I bombard him with 128 bits every nanosecond of questions about SIMD and pointers.</p>



<a name="242798816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Scatter/Gathers/near/242798816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Scatter.2FGathers.html#242798816">(Jun 15 2021 at 20:58)</a>:</h4>
<p>Okay, rebuilt my scatter/gather branch and somehow the way I redid it this time to "properly" add in pointers and scatter/gather and such causes "unused" errors to not be emitted in most cases. Go figure.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>